Everything has an Interface [closed]

Posted by Shane on Programmers See other posts from Programmers or by Shane
Published on 2012-10-15T19:01:24Z Indexed on 2012/10/15 21:48 UTC
Read the original article Hit count: 259

Possible Duplicate:
Do I need to use an interface when only one class will ever implement it?

I am taking over a project where every single real class is implementing an Interface. The vast majority of these interfaces are implemented by a single class that share a similar name and the exact same methods (ex: MyCar and MyCarImpl). Almost no 2 classes in the project implement more than the interface that shares its name.

I know the general recommendation is to code to an interface rather than an implementation, but isn't this taking it a bit too far? The system might be more flexible in that it is easier to add a new class that behaves very much like an existing class. However, it is significantly harder to parse through the code and method changes now require 2 edits instead of 1.

Personally, I normally only create interfaces when there is a need for multiple classes to have the same behavior. I subscribe to YAGNI, so I don't create something unless I see a real need for it. Am I doing it all wrong or is this project going way overboard?

© Programmers or respective owner

Related posts about java

Related posts about programming-practices